package com.llc.mall.user.infrastructure.feign;

import com.llc.mall.user.application.query.service.UserAddrQueryService;
import com.llc.mall.user.interfaces.vo.UserAddrVo;
import com.mall4j.cloud.api.user.feign.UserAddrFeignClient;
import com.llc.mall.common.order.vo.UserAddrVO;
import com.llc.mall.common.core.response.ServerResponseEntity;
import com.llc.mall.common.security.AuthUserContext;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户地址feign连接
 * @author 
 * @date 2020/12/07
 */
@RestController
public class UserAddrFeignController implements UserAddrFeignClient {

    @Autowired
    private UserAddrQueryService userAddrService;

    @Override
    public ServerResponseEntity<UserAddrVO> getUserAddrByAddrId(Long addrId) {
        UserAddrVo vo = userAddrService.getUserAddrByUserId(addrId,AuthUserContext.get().getUserId());
        UserAddrVO res = new UserAddrVO();
        BeanUtils.copyProperties(vo, res);
        return ServerResponseEntity.success(res);
    }
}
